﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/NoMenuMaster.Master" AutoEventWireup="true" CodeBehind="Cipher1.aspx.cs" Inherits="Besture.UI.Email.Cipher1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <div class="main">
		<div class="w980">
        	<table width="100%" class="cipher-tab">
              <tr>
                <td colspan="2" class="cipher-fonta">短信验证码已经发送到您的手机<asp:Label ID="labTelphone" runat="server" Text="138******10"></asp:Label>上，请在下框中输入验证码：</td>
              </tr>
              <tr>
                <td class="cipher-td"><span>*</span> 验证码：</td>
                <td class="cipher-tds"><input id="txtVailidCode" runat="server" type="text" value="" class="required cipher-in1" name="one1" placeholder="请输入验证码"/></td>
              </tr>
              <tr class="errortr">
                 <td class="cipher-td">&nbsp;</td>
                 <td id="EmailError">&nbsp;</td>
              </tr>
              <tr>
              	 <td class="cipher-td">&nbsp;</td>
                 <td class="cipher-a"><a id="checkcode" href="javascript:void(0);" onclick="return CheckCode();" >重新发送验证码</a></td>
              </tr>
              <tr>
                <td class="cipher-td">&nbsp;</td>
                <td class="cipher-tda1"><asp:Button ID="btnFind" runat="server" Text="提交" 
                        onclick="btnFind_Click" /></td>
              </tr>
            </table>
        </div>
	</div>
    <input id="txtTelphone" runat="server" type="hidden" value="" />
    <script type="text/javascript">
        $(function () {
            $("#aspnetForm").validate({
                errorPlacement: function (error, element) {

                    error.appendTo(element.parent().parent().next(".errortr").children("td:eq(1)"));
                }
            });
        })
</script>

<script type="text/javascript">
    //获取手机验证码按钮验证
    var t;
    function CheckCode() {

        var vtxt = $("#checkcode").html();
        if (vtxt != "重新发送验证码" && vtxt != "重新发送验证码") {
            return false;
        }
        if ($("#<%=txtTelphone.ClientID %>").val() != "") {
            var Telphone = $("#<%=txtTelphone.ClientID %>").val();
            var reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
            var emailExp = new RegExp(reg);
            if (emailExp.test(Telphone)) {
                //异步验证手机
                $("#checkcode").html("请稍后");
                $.post("/ajax/AjaxPage.aspx?SendSMSF=" + Telphone + "",
                    function (data1) {
                        if ($("#hidIsOnLine").val() == "0") {
                            //alert(data1);
                            DelaySend();
                        } else {
                            if (data1 == "1") {
                                alert("验证码已发送，请确认查收");
                                DelaySend();
                            }
                        }
                    }
                );
            } else {
                $("#EmailError").html("输入手机号不正确，请重新输入");
                $("#EmailError").removeClass();
                $("#EmailError").addClass("Red");
                $("#<%=txtTelphone.ClientID %>").focus();
            };

        } else {
            $("#EmailError").html("手机号不能为空，请输入手机号");
            $("#EmailError").removeClass();
            $("#EmailError").addClass("Red");
            $("#<%=txtTelphone.ClientID %>").focus();
        }
    }

    //错误消失
    $("#<%=txtTelphone.ClientID %>").bind({
        focus: function () {
            $("#EmailError").html(" ");
            $("#EmailError").removeClass();
            $("#EmailError").addClass("Red");
        }
    });

    //发送成功后执行
    function DelaySend() {
        t = setInterval(timer, 1000); //发送成功之后数秒
    };

    //手机注册时间计时
    var sumSecond = 299;
    var scrollTimer = 4;
    function timer() {
        if (sumSecond <= 0) {
            $("#checkcode").html("重新发送验证码");
            clearInterval(t);
            sumSecond = 299;
            scrollTimer = 4;
            return 0;
        }
        if (scrollTimer > 0) {
            $("#checkcode").html(scrollTimer + 1 + "分钟后重发");
        }
        else {
            $("#checkcode").html(sumSecond + "秒后重发");
        }
        sumSecond -= 1;
        if (sumSecond / 60 == scrollTimer) {
            scrollTimer -= 1;
        }
    }
</script>
</asp:Content>
